import QtQuick
import QtQuick.Particles

Rectangle {
    width: 400
    height: 400
    color: "black"

    ParticleSystem {
        id: explosionSystem
        anchors.fill: parent

        ImageParticle {
            source: "qrc:/images/star.png"
            color: "#FFFF00"
            colorVariation: 0.5
            alpha: 0.8
            alphaVariation: 0.2
        }

        Emitter {
            id: explosionEmitter
            system: explosionSystem
            x: 200
            y: 200
            emitRate: 1000
            lifeSpan: 1000
            size: 24
            sizeVariation: 8
            endSize: 4
            velocity: AngleDirection {
                angle: 0
                angleVariation: 360
                magnitude: 200
                magnitudeVariation: 50
            }
            acceleration: PointDirection {
                y: 50
            }

            // 只发射一次
            onEmitParticles: explosionEmitter.enabled = false
        }

        Timer {
            interval: 3000
            running: true
            repeat: true
            onTriggered: {
                explosionEmitter.enabled = true
                explosionEmitter.burst(500)
            }
        }
    }
}
